# 使用单线程模拟下载
import time
from multiprocessing.dummy import Pool


def get_page(str):
    print("正在下载： ", str)
    time.sleep(2)
    print('下载成功', str)

# 使用线程池模拟下载


if __name__ == '__main__':
    name_list = ['xiaozi', 'aa', 'bb', 'cc']
    start_time = time.time()
    for i in range(len(name_list)):
        get_page(name_list[i])
    end_time = time.time()
    print('%d second' % (end_time - start_time))

    start_time = time.time()
    pool = Pool(4)
    pool.map(get_page, name_list)
    end_time = time.time()
    print('%d second' % (end_time - start_time))
